﻿using System;
using System.Collections;
using System.Collections.Generic;

using AUV5.Model;
using AUV5.DAL.Interface;

namespace AUV5.DAL.Dao
{
    /// <summary>
    /// 功能：     OrderStatusLog业务接口的实现
    /// 作者：     Wilson
    /// 日期：     2011/12/4
    /// 修改日期： 
    /// 修改人：
    /// 修改内容：
    /// </summary>
    public class OrderStatusLogSqlMapDao : BaseSqlMapDao, AUV5.DAL.Interface.IOrderStatusLogDao
    {
        private static OrderStatusLogSqlMapDao instance = new OrderStatusLogSqlMapDao();

        private OrderStatusLogSqlMapDao()
        {
            //
            // TODO: 此处添加OrderStatusLogSqlMapDao的构造函数
            //
        }

        public static IOrderStatusLogDao GetInstance()
        {
            return instance;
        }

        /// <summary>
        /// 得到最大行数
        /// </summary>
        /// <returns></returns>
        public int GetMaxCounts()
        {
            try
            {
                return (int)ExecuteQueryForObject("SelectOrderStatusLogByMaxCounts", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到列表
        /// </summary>
        /// <returns></returns>
        public System.Collections.Generic.IList<OrderStatusLog> GetList()
        {
            try
            {
                return ExecuteQueryForList<OrderStatusLog>("SelectOrderStatusLog", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 通过不同参数得到列表
        /// </summary>
        /// <param name="objParameters"></param>
        /// <returns></returns>
        public System.Collections.Generic.IList<OrderStatusLog> GetListByParameters(object objParameters)
        {
            try
            {
                return ExecuteQueryForList<OrderStatusLog>("SelectOrderStatusLogByParameters", objParameters);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到明细
        /// </summary>
        /// <param name="LogId"></param>
        /// <returns></returns>
        public OrderStatusLog GetDetail(System.String logid)
        {
            try
            {
                return ExecuteQueryForObject<OrderStatusLog>("SelectOrderStatusLog", logid) as OrderStatusLog;
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 新建
        /// </summary>
        /// <param name="orderstatuslog"></param>
        /// <returns></returns>
        public object Add(OrderStatusLog orderstatuslog)
        {
            //int id = GetId("OrderStatusLog");
            //orderstatuslog.LogId = id;

            try
            {
                return ExecuteInsert("InsertOrderStatusLog", orderstatuslog);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="orderstatuslog"></param>
        /// <returns></returns>
        public int Update(OrderStatusLog orderstatuslog)
        {
            try
            {
                return ExecuteUpdate("UpdateOrderStatusLog", orderstatuslog);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="LogId"></param>
        /// <returns></returns>
        public int Delete(System.String logid)
        {
            try
            {
                return ExecuteDelete("DeleteOrderStatusLog", logid);
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="orderstatuslog"></param>
        /// <returns></returns>
        public int Delete(OrderStatusLog orderstatuslog)
        {
            try
            {
                return ExecuteDelete("DeleteOrderStatusLog", orderstatuslog.LogId);
            }
            catch
            {
                throw;
            }
        }

        #region##通过订单ID得到订单状态日志
        /// <summary>
        /// 通过订单ID得到订单状态日志
        /// 创建人：Wilson
        /// 创建时间：2011-12-4
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public OrderStatusLog GetOrderStatusLogByOrderId(string orderId)
        {
            try
            {
                return ExecuteQueryForObject<OrderStatusLog>("SelectOrderStatusLogByOrderId", orderId) as OrderStatusLog;
            }
            catch
            {
                throw;
            }
        }
        #endregion


    }
}
